package com.minsf.springbootinit.awareTest;

import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author minify
 * @Date 2024/1/2 14:57
 * @Project oj-backend
 */
@Component
public class DemoFieldAwarePostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(@NotNull Object bean, @NotNull String beanName) throws BeansException {
        if (bean instanceof DemoFieldAware) {
            ((DemoFieldAware)bean).setDemoField("向外暴露属性推送...");
        }
        return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
    }
}
